{layout name="public/layout" /}
{include file='yxnavbar'}


{include file='sms/sms_header'}
<style>
    .mobile_style{
        background: url("{$mobile_bg_img}");
        background-size: contain;
        /*background-size: 296px 609px;*/
        background-repeat: no-repeat;
        width: 336px;
        height: 609px;
        border-radius: 40px;
        -webkit-box-shadow: 1px 2px 24px 0 rgba(0,0,0,.08);
        box-shadow: 1px 2px 24px 0 rgba(0,0,0,.08);
        border: 1px solid lightgray;
        position: relative;
    }
    .sms_title{
        margin-left: 25%;
        font-size: 22px;
        font-weight: 600;
        height: 50px;
        line-height: 30px;
    }
    .mode_change{
        display: flex;flex-direction: column;
        margin-top: 80px;
        width: 28px;
        margin-right: 1%;
    }
    .mode_change_item{
        text-align: center;
        padding: 8px;
        background-color: #e6ebed;
        margin-top: 4px;
    }
    .mode_change_item_active{
        background-color: #428bca !important;
        color: #fff !important;
    }
    .mobile_container{
        height: 400px;
        position: absolute;
        width: 94%;
        top: 104px;
        left: 8px;
    }
    .mobile_containe_content{
        position: absolute;
        left: 20px;
        max-width: 232px;
        padding: 8px 10px;
        color: #333;
        background-color: #e9e9eb;
        border-radius: 16px;
        word-break: break-all;
    }
    .mobile_containe_content:before{
        content: " ";
        display: inline-block;
        position: absolute;
        background-image: url("{$mobile_msg_img}");
        background-repeat: no-repeat;
        width: 18px;
        height: 10px;
        left: -5px;
        bottom: 0;
    }
    .mobile_container_edit{
        padding: 10px 2px 0;
    }
    .mobile_container_edit_main{
        position: relative;
        box-sizing: border-box;
    }
    .mobile_container_edit_main_label{
        position: absolute;
        top: 7px;
        left: 5px;
        z-index: 1;
        box-sizing: border-box;
    }
    .mobile_container_edit_main_textarea{
        min-height: 206px;
        max-height: 288px;
        text-indent: 87px;
        border-radius: 4px;
        position: relative;
        display: inline-block;
        width: 100%;
        border: 1px solid #ccd5db;
        padding: 5px 10px;
        color: rgba(0,0,0,.65);
        text-indent: 50px;
        line-height: 1.5;
    }
    .sms_content_tips{
        min-height: 100px;
        border-radius: 4px;
        padding: 12px;
        font-size: 14px;
        line-height: 20px;
        margin-left: 6%;
        background-color: #e7f4ff;color: #666;
        display: none;
    }
    .sms_content_tips_danger{
        min-height: 100px;border-radius: 4px;padding: 12px;color: #ff5448;font-size: 14px;line-height: 20px;margin-left: 6%;margin-top: 10px;
        display: none;
    }
    .mobile_container_edit_main_span{
        position: absolute;
        right: 16px;
        bottom: 6px;
        font-size: 12px;
        color: #999;
        line-height: 17px;
    }
</style>
<form class="form-horizontal form" action="" id="form1"  method="post" enctype="multipart/form-data">
    <div class="panel panel-info" role="tabpanel" style="">
<!--        <div class="panel-heading" style="background-color: #478ec8;color: #ffffff;">快速群发</div>-->
        <div class="panel-body" style="display: flex;flex-direction: row;">
<!--            左侧-->
            <div style="width: 60%;">

                <!--内置快速模板-->
                <div class="form-group" id="yx_sms_system_from_ll"  style="display: none;">
                    <label class="col-sm-1 col-xs-12 control-label" style="width: 12%;"><span style="color: red;">*</span>选择短信模板</label>
                    <div class="col-sm-10 col-xs-12" >
                        <select class="form-control" id="yx_sms_llcurrency_type" name="yx_sms_llcurrency_type" onchange="yx_sms_ll()">
                            <option value="0" data-type="default" data-head="" data-tail="">----------选择短信模板----------</option>
                            {loop $llcurrency  $val}
                            <option value="{$val['id']}" data-head="{$val['head']}" data-tail="{$val['tail']}">{$val['head']}</option>
                            {/loop}
                        </select>
                    </div>
                </div>

<!--                <div class="form-group" id="yx_sms_system_from_time" style="display: none;">-->
<!--                    <label class="col-sm-1 col-xs-12 control-label" style="width: 12%;">下单时间</label>-->
<!--                    <div class="col-sm-10 col-xs-12">-->
<!--                        {php echo view_form_field_daterange('adtime', array('start'=>date('Y-m-d H:i:s',$search_start),'end'=>date('Y-m-d H:i:s',$search_end)), true);}-->
<!--                        <span class="help-block">手机号客户的下单时间</span>-->
<!--                    </div>-->
<!--                </div>-->
                <div class="form-group" style="text-align: right;">
                    <input name="submit"  style="position: relative;left: 69%;" onclick="popup()"  type="button" value="导入" class="btn btn-primary col-lg-2">
                </div>

                <div class="form-group" id="sms_input_mobile" >
                    <label class="col-sm-1 col-xs-12 control-label" style="width: 12%;">发送手机号</label>
                    <div class="col-sm-9 col-xs-12">
                        <textarea rows="10" cols="30" class="form-control" id="mobile_list" {if $mobile_str}readonly="readonly"{/if}>{$mobile_str}</textarea>
                        <span class="help-block">一行一个手机号，重复数据系统会自动删除；单次最多1万个手机号</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-1 col-xs-12 control-label" style="width: 12%;">短信内容</label>
                    <div class="col-sm-9 col-xs-12">
                        <textarea rows="5" cols="50" class="form-control" id="quick_template" {if $wait_item['out_template_content']}readonly="readonly"{/if}
                        >{$wait_item['out_template_content']}</textarea>
                    </div>
                </div>
                {if $system['softmode']==0||$system['softmode']==2}
                    <div class="form-group">
                        <label class="col-sm-1 col-md-1 col-lg-1 control-label" style="width: 12%;">插入列</label>
                        <div class="col-sm-9 col-xs-12">
                            <button  class="layui-btn layui-btn-primary layui-border-green" onClick="insertSmsTag(this)" type="button" data-type="活动网址">活动网址</button>
                        </div>
                    </div>
                {/if}
                <div class="form-group">
                    <label class="col-sm-1 col-xs-12 control-label" style="width: 12%;">定时发送</label>
                    <div class="col-sm-9 col-xs-12">
                        <label class="radio-inline">
                            <input name="timed_transmission" value="0"  checked="checked" type="radio"> 关闭
                        </label>
                        <label class="radio-inline">
                            <input name="timed_transmission" value="1"  type="radio"> 开启
                        </label>
                    </div>
                </div>
                <div class="form-group" id="yx_fixed_time" style="display: none;">
                    <label class="col-sm-1 col-xs-12 control-label" style="width: 12%;">定时时间</label>
                    <div class="col-sm-9 col-xs-24">
                        <div class="layui-input-inline" >
                            <div class="col-sm-6 col-xs-12">
                                <input type="text" style="display: inline;" class="layui-input" id="test5" name="fixed_time" placeholder="年-月-日">
                            </div>
                            <div class="col-sm-6 col-xs-12">
                                <input type="text" class="layui-input" id="test6" name="fixed_time1" placeholder="时-分-秒">
                            </div>
                        </div>
                    </div>
                </div>

<!--按钮-->
                <div class="col-sm-12">
                    <input style="" name="submit" id="btnConfirm8" type="button" value="发送" class="btn btn-primary col-lg-3" style="width:120px;">

                    <input type="hidden" name="__token__" value="{$Request.token}" />
                </div>
            </div>
<!--            右侧-->
            <div style="width: 45%;">
                <div style="display: flex;flex-direction: row;">
<!--                    <div class="mode_change" >-->
<!--                        <div class="mode_change_item " data-type="edit">编辑模式</div>-->
<!--                        <div class="mode_change_item mode_change_item_active" data-type="read">预览模式</div>-->
<!--                    </div>-->
                    <div class="mobile_style" >
                        <div class="mobile_container">
                            <div class="mobile_container_edit" style="display: none;">
                                <div class="mobile_container_edit_main">
                                    <label class="mobile_container_edit_main_label">{php echo $sign_name;}</label>
                                    <textarea class="mobile_container_edit_main_textarea" maxlength="500" id="quick_template" {if $wait_item['out_template_content']}readonly="readonly"{/if}>{$wait_item['out_template_content']}</textarea>
<!--                                    <span class="mobile_container_edit_main_span"><span class="input_text_length">6</span>/500</span>-->
                                </div>
                                <div style="display: flex;flex-direction: row;justify-content: space-around;">
                                    <div style="color: #666;font-size: 12px;text-shadow: rgba(0,0,0,0.08);">请在 <span>{php echo $sign_name;}</span>之后输入内容</div>
                                    <div style="color: #1261ff;font-size: 12px;text-shadow: rgba(0,0,0,0.08);">短信制作规范</div>
                                </div>
                            </div>
                            <div class="mobile_containe_content" ></div>
                            <div class="mobile_container_edit_main_span"><span class="input_text_length">6</span>/500</div>
                        </div>
                    </div>
                    <div style="width: 40%;margin-top: 12%;" >
                        <div  class="sms_content_tips" >
                            计费：当前设置的短信内容，每次发送会消耗<span class="sms_content_tips_sms_total">1</span>条短信，计费<span class="sms_content_tips_sms_amount">0.2</span>元,<a style="color: #428bca;" onclick="showSmsPriceDesc();" href="#">点击查看</a>计费方式
                        </div>
                        <div class="sms_content_tips_danger">
                            计费：当前设置的短信内容，每次发送会消耗一条短信，计费0.1元,计费方式
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
<!--弹窗-->
    <div class="virtual"  style="width: 40vw;height: 40vh;z-index:10;display:none;position: fixed;top: 50%;left: 50%;transform: translate(-50%,-50%) ">
        <div class="panel panel-info">
            <div class="panel-heading" style="background-color: #428bca;color: #f7f7f7;">
                <span>检索手机号</span>
                <span class="close_virtual" onclick="aclose()" style="float: right;">关闭</span>
            </div>
            <div class="panel-body">
                <form id ="myform1"  class="form-horizontal" role="form" style="margin: 0 auto;">
                    <div class="form-group" id="yx_sms_system_from" style="display: none;">
                        <label class="col-sm-1 col-xs-12 control-label" style="width: 12%;"><span style="color: red;">*</span>选择客户分类</label>
                        <div class="col-sm-10 col-xs-12">
                            <select class="form-control" id="yx_sms_mobile_type" name="yx_sms_mobile_type">
                                <option value="0" data-type="default">----------请选择客户分类----------</option>
                                {loop $sms_system_mobile_type  $val}
                                <option value="{$val['val']}" data-type="{$val['type']}">{$val['title']}【{$val['count']}】</option>
                                {/loop}
                            </select>
                        </div>
                    </div>
                    <div class="form-group" style="display: none;" id="match_mobile_desc">
                        <label class="col-sm-1 col-xs-12 control-label" style="width: 12%;">匹配说明</label>
                        <div class="col-sm-10 col-xs-12">
                            <input class="form-control" id="match_mobile_desc_input" value="" readonly>
                        </div>
                    </div>
                    <input name="submit" onclick="checkOrderSmsMobilell()" style="display: none;" id="btnConfirmll" type="button" value="检索手机号" class="btn btn-primary col-lg-2">

                </form>
            </div>
        </div>
    </div>
</form>


<script type="text/javascript">
    var tail = '拒收请回复R';
    var tail_length = tail.length;
    var head = '';
    var head_length = 0;
    var show_text1 = "{php echo $sign_name;}";
    var open_yx_sms = "{php echo $open_yx_sms;}";
    var timed_transmission = '0';
    var act_url =  "{$index_url}";
    function popup(){
        $('.virtual').show();
        $('#yx_sms_system_from').show();
        $('#btnConfirmll').show();
    }
    function aclose(){
        $('.virtual').hide();
    }
    function yx_sms_ll(){
        var yx_sms_llcurrency_type_head = $("#yx_sms_llcurrency_type").find('option:selected').attr("data-head");
        var yx_sms_llcurrency_type_tail = $("#yx_sms_llcurrency_type").find('option:selected').attr("data-tail");
        head =yx_sms_llcurrency_type_head;
        tail =yx_sms_llcurrency_type_tail;
        show_text1 = "{php echo $sign_name;}"+yx_sms_llcurrency_type_head;
        $('.input_text_length').html(show_text1.length+yx_sms_llcurrency_type_tail.length);
        $('.mobile_containe_content').html(show_text1+yx_sms_llcurrency_type_tail);
    }
    //内置快速模板
    $("#btnConfirm8").click(function () {
        var mobile_list = $('#mobile_list').val();
        if(mobile_list.length<11){
            layer.msg('请填写手机号');
            return;
        }

        var quick_template = $("#quick_template").val();
        if (quick_template.length==0){
            layer.msg('请输入短信内容');
            return;
        }
        var fixed_time = $("input[name=fixed_time]").val();
        var fixed_time1 = $("input[name=fixed_time1]").val();
        if(timed_transmission==1){
            if(fixed_time=='undefined'||fixed_time==''||fixed_time1=='undefined'||fixed_time1==''){
                layer.msg('请选择定时时间');
                return;
            }
        }
        // 获取选中的值
        var yx_sms_llcurrency_id = $('#yx_sms_llcurrency_type').val();
        var content = $("#quick_template").val();

        let postUrl = "{php echo createWebUrl('sms',array('op'=>'check_mobile','themeid'=>$themeid));}";
        $.ajax({
            url:postUrl,
            dataType:'json',
            method:'post',
            data:{mobile_list:mobile_list},
            success:function (e) {
                let status = e.status;
                let result = e.result;
                var sure = result.data.sure;
                var mobile_txt = result.data.mobile_txt;
                if (status!=1){
                    layer.msg(result.msg)
                }else{
                    layer.confirm("确认录入（共 "+sure +" 个）并提交审核", {
                        btn: ['是','否'], //按钮
                        title:'是否提交审核'
                    }, function(){
                        if(sure>10000){
                            layer.msg('超过一万条！');
                            return;
                        }
                        var inde = layer.load(2);
                        $.ajax({
                            url:"{php echo createWebUrl('sms',array('op'=>'ll_shortcut','themeid'=>$themeid));}",
                            dataType:'json',
                            method:'post',
                            data:{
                                mobile_txt:mobile_txt,
                                template_id:yx_sms_llcurrency_id,
                                content:content,
                                head:head,
                                tail:tail,
                                timed_transmission:timed_transmission,
                                fixed_time:fixed_time,
                                fixed_time1:fixed_time1,
                            },
                            success:function (e) {
                                layer.close(inde);
                                if(e.error==200){
                                    layer.msg(e.msg);
                                    setTimeout(function () {
                                        window.location.reload();
                                    },1500);
                                }else{
                                    layer.msg(e.msg);
                                }
                            },
                            fail:function (err) {
                                console.log(err)
                            }
                        })
                    });
                    return;
                }
            },
            fail:function (err) {
                console.log(err)
            }
        })

    })
    $(document).ready(function () {
        var default_str_length = 4;
        var input_text = $('#quick_template').val();
        var input_text_length = input_text.length;
        var total_text_length = default_str_length+input_text_length+head.length+tail.length;
        if (input_text_length<1){
            $('.sms_content_tips').hide();
            $('.sms_content_tips_danger').hide();
        }
        var sms_content_tips_sms_total=1;
        var sms_content_tips_sms_amount = '0.1';
        if (input_text_length>0){
            sms_content_tips_sms_total = Math.ceil(total_text_length/67);
            sms_content_tips_sms_amount = sms_content_tips_sms_total/10;
            $('.sms_content_tips_sms_total').html(sms_content_tips_sms_total);
            $('.sms_content_tips_sms_amount').html(sms_content_tips_sms_amount);
            $('.sms_content_tips').show();
        }
        if(tail=='undefined'&&head=='undefined'){
            var show_text =  show_text1+$(this).val();
        }else{
            var show_text =  show_text1+$(this).val()+tail;
        }
        $('.input_text_length').html(total_text_length);
        $('.mobile_containe_content').html(show_text);
    });
    //定时发送开关
    $("input:radio[name=timed_transmission]").change(function () {
        var _this = $(this);
        timed_transmission = _this.val();
        if (_this.val()==0) {
            $('#yx_fixed_time').hide();
        }
        if (_this.val()==1) {
            $('#yx_fixed_time').show();
        }
    });
//日期选择
    layui.use('laydate', function(){
        var myDate = new Date();  //获取当前时间
        var laydate = layui.laydate;
        laydate.render({
            elem: '#test5'
            ,type: 'date'
            ,min:myDate.toLocaleString()  //转化当前时间格式
            ,max: 7 //7天后
            ,done: function(value, date, endDate){
                var myTime = new Date();
                var lastHour =   myTime.setHours(myTime.getHours() + 1);
                var lastTime = new Date(lastHour);
                var hour = lastTime.getHours();
                $('#test6').val(hour+':00:00');
                //selTime.config.min = myTime.toLocaleString();
            }
        });
        laydate.render({
            elem: '#test6'
            ,type: 'time'
            //,min:myDate.toLocaleString()
        });
    });
    //
    $("input:radio[name=yx_sms_input_type]").change(function () {
        var _this = $(this);
        head = '';
        tail = '';
        show_text1 = "{php echo $sign_name;}";
        $('.input_text_length').html(show_text1.length);
        $('.mobile_containe_content').html(show_text1);
        if (_this.val()==0) {
            $('#sms_input_mobile').show();
            $('#btnConfirm').show();
            $('#btnConfirm2').hide();
            $('#btnConfirm8').hide();
            $('#yx_sms_system_from').hide();
            $('#yx_sms_system_from_ll').hide();
            $('#yx_sms_system_from_time').hide();
            $('#btnConfirmll').hide();
        }
        if (_this.val()==1){
            $('#sms_input_mobile').hide();
            $('#btnConfirm').hide();
            $('#btnConfirm8').hide();
            $('#btnConfirm2').show();
            $('#yx_sms_system_from').show();
            $('#yx_sms_system_from_ll').hide();
            $('#yx_sms_system_from_time').show();
            $('#btnConfirmll').hide();

        }
        if (_this.val()==2) {
            $('#sms_input_mobile').show();
            $('#btnConfirm').hide();
            $('#btnConfirm2').hide();
            $('#btnConfirm8').show();
            $('#yx_sms_system_from').show();
            $('#yx_sms_system_from_ll').show();
            $('#yx_sms_system_from_time').show();
            $('#btnConfirmll').show();
        }
    });
    function checkOrderSmsMobilell(){
        checkOrderSmsMobile('ll')
    }
    function checkOrderSmsMobile(ll) {
        var yx_sms_mobile_type = $("#yx_sms_mobile_type").val();
        var yx_sms_mobile_type_type = $("#yx_sms_mobile_type").find('option:selected').attr("data-type");
        var start_time = $("input[name='adtime[start]']").val();
        var end_time = $("input[name='adtime[end]']").val();
        console.log(start_time)
        console.log(end_time)
        console.log(yx_sms_mobile_type)
        if (!yx_sms_mobile_type || yx_sms_mobile_type==0){
            layer.msg('请选择客户分类');
            return
        }
        $("#btnConfirm2").attr("disabled","true");
        layer.msg('检索手机号...');
        var postUrl = "{php echo createWebUrl('sms',array('op'=>'betch_ali_match','themeid'=>$themeid));}";
        $.ajax({
            url:postUrl,
            dataType:'json',
            method:'post',
            data:{mobile_type:yx_sms_mobile_type,mobile_type_type:yx_sms_mobile_type_type,start_time:start_time,end_time:end_time},
            success:function (e) {
                let status = e.status;
                let result = e.result;
                $("#btnConfirm2").removeAttr("disabled");
                // if (status!=1){
                //     layer.msg(result.msg)
                // }else{
                    var total = result.data.total;
                    var mobile = result.data.mobile_txt;
                    $("#mobile_list").html(mobile);
                    $("#sms_input_mobile").show();
                    var show_txt = '匹配到'+total+'个手机号';
                    $("#match_mobile_desc_input").val(show_txt);
                    $("#match_mobile_desc").show();
                    if(ll!='ll'){
                        $("#btnConfirm2").hide();
                        $("#btnConfirm").show();
                        $("#btnConfirm3").show();
                    }

                // }
            },
            fail:function (err) {
                console.log(err)
            }
        })
    }

    //插入短信标签
    function insertSmsTag(e) {
        let tmp_val= '';
        let lay_msg = '超过文字长度限制';
        let tmp_type = e.getAttribute("data-type");
        if(tmp_type=='活动网址'){
            tmp_val = act_url;
        }
        if (!inLimitTxtLength(tmp_val)){
            layer.msg(lay_msg);
            return
        }
        //追加文本
        $("#quick_template").insertAtCaret(tmp_val);
        changeSms($("#quick_template").val());
    }

    (function ($) {
        $.fn.extend({
            insertAtCaret: function (myValue) {
                var $t = $(this)[0];
                if (document.selection) {
                    this.focus();
                    sel = document.selection.createRange();
                    sel.text = myValue;
                    this.focus();
                } else
                if ($t.selectionStart || $t.selectionStart == '0') {
                    var startPos = $t.selectionStart;
                    var endPos = $t.selectionEnd;
                    var scrollTop = $t.scrollTop;
                    $t.value = $t.value.substring(0, startPos) + myValue + $t.value.substring(endPos, $t.value.length);
                    this.focus();
                    $t.selectionStart = startPos + myValue.length;
                    $t.selectionEnd = startPos + myValue.length;
                    $t.scrollTop = scrollTop;
                } else {
                    this.value += myValue;
                    this.focus();
                }
            }
        })
    })(jQuery);

    var open_yx_sms = "{php echo $open_yx_sms;}";
    $("#btnConfirm").click(function () {
        if (open_yx_sms==0){
            layer.msg(' 【 短信通知未开通 】 开通请到 "群发短信" => "短信配置" 中开启，如有疑问请联系客服！');
            return;
        }
        var quick_template = $("#quick_template").val();

        if (quick_template.length==0){
            layer.msg('请输入短信内容');
            return;
        }
        // var remark = $("#remark").val();
        // if (remark.length==0){
        //     layer.msg('请输入短信使用说明');
        //     return;
        // }

        $("#btnConfirm").attr("disabled","true");
        //短信内容审核
        var content = $("#quick_template").val();
        var check_url = "{php echo createWebUrl('sms',array('op'=>'audio_sms_content','themeid'=>$themeid));}";
        $.ajax({
            url:check_url,
            dataType:'json',
            method:'post',
            data:{content:content},
            success:function (e) {
                let status = e.status;
                let result = e.result;
                if (status!=1){
                    layer.msg(result.msg)
                }else{
                    var filter_word_count = result.data.filter_word_count;
                    var filter_word_log = result.data.filter_word_log;
                    if (filter_word_count>0){
                        layer.msg(filter_word_log);
                        $("#btnConfirm").removeAttr("disabled");
                        return;
                    }
                }

            },
            fail:function (err) {
                console.log(err)
            }
        });
        var mobile_list = $('#mobile_list').val();
        let postUrl = "{php echo createWebUrl('sms',array('op'=>'check_mobile','themeid'=>$themeid));}";
        $.ajax({
            url:postUrl,
            dataType:'json',
            method:'post',
            data:{mobile_list:mobile_list},
            success:function (e) {
                let status = e.status;
                let result = e.result;
                if (status!=1){
                    layer.msg(result.msg)
                }else{
                    var mobile_txt = result.data.mobile_txt;
                    var sure = result.data.sure;
                    $('#btnConfirm').hide();
                    $('#chongfu_div').show();
                    $('#chongfu').html(result.msg);
                    $('#submit_Confirm').val("确认录入（共 "+sure +" 个）并提交审核");
                    $('#mobile_list').attr("readonly","readonly");
                    $('#quick_template').attr("readonly","readonly");
                    $('#remark').attr("readonly","readonly");
                    $("#mobile_list").val(mobile_txt);
                    layer.msg(result.msg);
                    $("#btnConfirm").removeAttr("disabled");
                }
            },
            fail:function (err) {
                console.log(err)
            }
        })
    });
    //确认提审
    $("#submit_Confirm").click(function () {
        $("#submit_Confirm").attr("disabled","true");
        var quick_template = $("#quick_template").val();
        var mobile_list = $('#mobile_list').val();
        var remark = $("#remark").val();
        let postUrl = "{php echo createWebUrl('sms',array('op'=>'quick_sms','themeid'=>$themeid));}";
        var jump_url = "{php echo createWebUrl('sms',array('op'=>'template_list','themeid'=>$themeid));}";
        $.ajax({
            url:postUrl,
            dataType:'json',
            method:'post',
            data:{mobile_list:mobile_list,quick_template:quick_template,remark:remark},
            success:function (e) {
                let status = e.status;
                let result = e.result;
                if (status!=1){
                    layer.msg(result.msg)
                    $("#btnConfirm").removeAttr("disabled");
                }else{
                    layer.msg(result.msg)
                    window.location.href = jump_url;
                }
            },
            fail:function (err) {
                console.log(err)
            }
        })
    });
    //展示测试短信
    function showSmsPriceDesc() {
        layer.open({
            type:1,
            area:['360px','220px'],
            title:'短信计费说明',
            content:'<div style="padding: 12px 16px;color: rgba(0,0,0,.65)">每条短信内容计费规则为：若短信内容不超过67字按1条计费。若超过67字，按照每67个字为1条计费，不足67部分也算作1条。短信字数含"签名+模版内容+变量内容”，以上包含汉字、中英文标点符号、英文字母、数字、短信签名、营销短信格式（回T退订）。每个汉字、中英文标点符号、英文字母、数字都占一个字。</div>'
        });
    }
    //文本域输入文字加默认短信模版头长度计数
    function changeSms(content){
        var default_str_length = 4;
        var input_text_length = content.length;
        var total_text_length = default_str_length+input_text_length+head.length+tail.length;
        if (input_text_length<1){
            $('.sms_content_tips').hide();
            $('.sms_content_tips_danger').hide();
        }
        if (total_text_length>=500){
            layer.msg('最大输入500个字符');
            return false;
        }
        var sms_content_tips_sms_total=1;
        var sms_content_tips_sms_amount = '0.1';
        if (input_text_length>0){
            sms_content_tips_sms_total = Math.ceil(total_text_length/67);
            sms_content_tips_sms_amount = sms_content_tips_sms_total/10;
            $('.sms_content_tips_sms_total').html(sms_content_tips_sms_total);
            $('.sms_content_tips_sms_amount').html(sms_content_tips_sms_amount);
            $('.sms_content_tips').show();
        }
        if(tail=='undefined'&&head=='undefined'){
            var show_text =  show_text1+content;
        }else{
            var show_text =  show_text1+content+tail;
        }
        $('.input_text_length').html(total_text_length);
        $('.mobile_containe_content').html(show_text);
    }
    $("#quick_template").keyup(function () {
         changeSms($(this).val());
    });

    function inLimitTxtLength(str) {
        var tmp_content_length = $("#quick_template").val().length;
        var input_txt_length = str.length;
        if (tmp_content_length+input_txt_length>500){
            return false;
        }
        return true;
    }

    //切换模式
    $(".mode_change_item").click(function (e) {
        $(this).addClass("mode_change_item_active").siblings().removeClass("mode_change_item_active");
        var data_type = $(this).attr('data-type');
        if (data_type=='read'){
            $(".mobile_container_edit").hide();
            $(".mobile_containe_content").show();
        }else{
            $(".mobile_container_edit").show();
            $(".mobile_containe_content").hide();
        }
    });
</script>
